package md.lanjing.com.module_mine.contact;

import android.content.Context;

import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;


import com.lxh.baselibray.constant.Constant;

import md.lanjing.com.module_mine.api.MineApiService;
import md.lanjing.com.module_mine.bean.MyDownPersonResopnce;
import retrofit2.Call;
import retrofit2.Response;

public class InviteCodeContact {
    public static class InviteCodePresent extends BasePresent<IInviteCodeView> {
        public void queryDownLineFriend(final Context context){
            MineApiService service= ServiceGenerator.createService(MineApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            service.queryDownLine(userId).enqueue(new NetCallBack<MyDownPersonResopnce>() {
                @Override
                public void onSuccess(Call<MyDownPersonResopnce> call, Response<MyDownPersonResopnce> response) {
                    if (getView()!=null){
                        getView().getDownLineFriendData(response);
                    }
                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,"网络请求异常");
                }
            });
        }
    }
    public interface IInviteCodeView extends IBaseView {
        void getDownLineFriendData(Response<MyDownPersonResopnce> response);
    }
}
